<?php
namespace Admin\Controller;
class DepostController extends AdminBaseController
{
   public function index()
    {
        if(session('auid')==null){
            $this->display('index/login');
            exit();
        }
        $this->display('depost/index');
        
    }
    
    public function depostlist(){
        if(session('auid')==null){
            $this->display('index/login');
            exit();
        }
        $page=I('page',1);
        $rows=I('rows',50);
        $start=($page-1)*$rows;
        $uid=I("uid",'');
        if($uid!=''){
            $cond['uid']=$uid;
        }
        $list = M("DepositLog")->where($cond)->order('createdate desc')->select();
        $count = M("DepositLog")->where($cond)->count();
        $map=array(
            'rows'=>$list,
            'total'=>$count
        );
        $this->ajaxReturn($map,'JSON');
    }  

  public function update(){
       if(session('auid')==null){
            $this->display('index/login');
            exit();
        }
        $status=I('status',0);
        $id=I('id',0);
        $DepositLog=M('DepositLog')->find($id);
        if(empty($DepositLog)){
            $map=array('status'=>4);
            $this->ajaxReturn($map,'JSON');
            exit();
        }
        $tixiantex=I('tixiantex'.'');
        if($status==2){
            M('UserAssets')->where('uid='.session('uid'))->setDec('locked_money',$DepositLog['dep_money']+$DepositLog['dep_fee']);
        }else{
            M('UserAssets')->where('uid='.session('uid'))->setDec('locked_money',$DepositLog['dep_money']+$DepositLog['dep_fee']);
            M('UserAssets')->where('uid='.session('uid'))->setInc('present_money',$DepositLog['dep_money']+$DepositLog['dep_fee']);
            M('UserAssets')->where('uid='.session('uid'))->setInc('avail_money',$DepositLog['dep_money']+$DepositLog['dep_fee']);
        }
        M("DepositLog")->where('id='.$id)->setField(array('status'=>$status,'adminremark'=>$tixiantex));
       $map=array('status'=>1);
       $this->ajaxReturn($map,'JSON');
       exit();
  }  

}